<div class="form-group">
    <?php /*<?php echo Form::label('title', '投票标题:', ['class' => 'control-label col-sm-2']); ?>*/ ?>
    <div class="col-sm-10">
        <?php /*<?php echo Form::text('title', null, ['class' => 'form-control']); ?>*/ ?>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-2 control-label">投票类型</label>
    <div class="col-sm-10 ">
        <?php /*<?php echo Form::radio('multiple', '<?php echo e(\App\Models\Vote::MULTIPLE_FALSE); ?>'); ?>单选*/ ?>
        <?php /*<?php echo Form::radio('multiple', '<?php echo e(\App\Models\Vote::MULTIPLE_TRUE); ?>'); ?>多选*/ ?>
    </div>
</div>

<div class="form-group file">
    <label class="col-sm-2 control-label">投票选项</label>
    <div class="col-sm-8">

        <?php if(isset($titles)): ?>
            <?php foreach($titles as $title): ?>
                <input type="text" id="item_title" name="item_title[]" class="form-control" value="<?php echo e($title); ?>"/>
                <div>
                    <button type="button" class="file_del1 btn btn-danger btn-xs margin-r-3 ">删除</button>
                    <button type="button" class="btn btn-primary btn-xs margin-r-3 add_file">增加</button>
                </div>
            <?php endforeach; ?>

        <?php else: ?>
            <input type="text" id="item_title" name="item_title[]" value="" class="form-control">
            <button type="button" class="file_del1 btn btn-danger btn-xs margin-r-3 ">删除</button>
            <button type="button" class="btn btn-primary btn-xs margin-r-3 add_file">增加</button>
        <?php endif; ?>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-2 control-label">上线时间</label>
    <div class="col-sm-10">
        <div class="input-group date begin_date col-md-5" data-date="2006-09-16 05:25"
             data-date-format="yyyy-mm-dd HH:ii" data-link-field="dtp_input1">
            <?php /*<?php echo Form::text('begin_date', null, ['class' => 'form-control']); ?>*/ ?>
            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
        </div>
    </div>

</div>

<div class="form-group">
    <label class="col-sm-2 control-label">下线时间</label>
    <div class="col-sm-10">
        <div class="input-group date end_date col-md-5" data-date="2006-09-16 05:25"
             data-date-format="yyyy-mm-dd HH:ii" data-link-field="dtp_input1">
            <?php /*<?php echo Form::text('end_date', null, ['class' => 'form-control']); ?>*/ ?>
            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
        </div>
    </div>
</div>


<div class="form-group">
    <?php /*<?php echo Form::label('description', '投票介绍:', ['class' => 'control-label col-sm-2']); ?>*/ ?>
    <div class="col-sm-10">
        <?php /*<?php echo Form::textarea('description', null, ['class' => 'form-control']); ?>*/ ?>
    </div>
</div>

<div class="box-footer">
    <a href="/votes" type="button" class="btn btn-default">取　消</a>
    <button type="submit" class="btn btn-info pull-right">确　定</button>
</div>

<script src="//cdn.bootcss.com/ckeditor/4.5.9/ckeditor.js"></script>

<script type="text/javascript" src="/plugins/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<link href="/plugins/datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>

<script>
    //开始时间
    $('.begin_date').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });

    //结束时间
    $('.end_date').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });

    CKEDITOR.replace('description',
            {
                filebrowserBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserImageBrowseUrl: '/plugins/ckfinder/ckfinder.html?type=Images',
                filebrowserFlashBrowseUrl: '/plugins/ckfinder/ckfinder.html?type=Flash',
                filebrowserUploadUrl: '/plugins/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                filebrowserImageUploadUrl: '/plugins/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
                filebrowserFlashUploadUrl: '/plugins/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
            });

    $(".add_file").click(function () {
        var i = $(".file").size();

        var n = i + 1;
        var html =
                '<div class="form-group file">' +
                '<label class="col-sm-2 control-label">附件(' + n + ')</label>' +
                '<div class="col-sm-8">' +
                '<input type="text" id="item_title" name="item_title[]" class="form-control" >' +
                '<button type="button" class="file_del btn btn-danger btn-xs margin-r-3" >删除</button>' +
                '</div>' +
                '</div>';

        <?php /*'<div class="form-group file">'+*/ ?>
                <?php /*'<label class="col-sm-2 control-label">附件(' + n + ')</label>'+*/ ?>
                <?php /*'<div class="col-sm-8">'+*/ ?>
                <?php /*'<?php if(isset($titles)): ?>'+*/ ?>
                <?php /*'<?php foreach($titles as $title): ?>'+*/ ?>
                <?php /*'<input type="text" id="item_title" name="item_title[]" class="form-control" value="<?php echo e($title); ?>"/>'+*/ ?>
                <?php /*'<div>'+*/ ?>
                <?php /*'<button type="button" class="file_del1 btn btn-danger btn-xs margin-r-3 ">删除</button>'+*/ ?>
                <?php /*'<button type="button" class="btn btn-primary btn-xs margin-r-3 add_file">增加</button>'+*/ ?>
                <?php /*'</div>'+*/ ?>
                <?php /*'<?php endforeach; ?>'+*/ ?>

                <?php /*'<?php else: ?>'+*/ ?>
                <?php /*'<input type="text" id="item_title" name="item_title[]" value="" class="form-control">'+*/ ?>
                <?php /*'<button type="button" class="file_del1 btn btn-danger btn-xs margin-r-3 ">删除</button>'+*/ ?>
                <?php /*'<button type="button" class="btn btn-primary btn-xs margin-r-3 add_file">增加</button>'+*/ ?>
                <?php /*'<?php endif; ?>'+*/ ?>
                <?php /*'</div>'+*/ ?>
                <?php /*'</div>';*/ ?>

        if (n < 6) {
            $(".file:last").after(html);
        } else {
            alert("您最多只能添加5个！");
            return false;
        }
        $(this).blur();

        //删除file的个数
        $(".file_del").click(function () {
            $(this).parent().parent().remove();
        })

        return false;
    })

    //清空第一个file的内容
    $(".file_del1").click(function () {
        $("#item_title").val('');
    })

</script>

